	var mtype=0;
	function GetQueryString(key) {
		// key为url变量名称
		var urlGets = location.search.substr(1);
		if(urlGets.length > 0) {
			start = urlGets.indexOf(key + '=');
			if(start != -1) {
				start = start + key.length + 1;
				end = urlGets.indexOf('&', start)
				if(end == -1) {
					end = urlGets.length
				}
				return decodeURIComponent(urlGets.substring(start, end))
			}
		}
		return '';
	}
	var userPicker;
	var userPicker1;
(function($, window, document, undefined) {
//	$.ready(function() {
		
			 userPicker = new $.PopPicker();
			 userPicker1 = new $.PopPicker();
			  
			userPicker.setData([{
				value: 'ywj',
				text: 500
			}, {
				value: 'aaa',
				text: 1000
			}, {
				value: 'aaa',
				text: 2000
			}, {
				value: 'aaa',
				text: 3000
			}, {
				value: 'lj',
				text: 4000
			}, {
				value: 'ymt',
				text: 5000
			}, {
				value: 'shq',
				text: 10000
			}, {
				value: 'zhbh',
				text: 15000
			}, {
				value: 'zhy',
				text: 20000
			}, {
				value: 'gyf',
				text: 30000
			}, {
				value: 'zhz',
				text: 50000
			}, {
				value: 'gezh',
				text: 100000
			}]);
			userPicker1.setData([{
				value: 'ywj',
				text: 1
			}, {
				value: 'aaa',
				text: 2
			}, {
				value: 'lj',
				text: 3
			}, {
				value: 'ymt',
				text: 6
			}, {
				value: 'shq',
				text: 12
			}, {
				value: 'zhbh',
				text: 18
			}, {
				value: 'zhy',
				text: 24
			}, {
				value: 'gyf',
				text: 36
			}, {
				value: 'zhz',
				text: 48
			}]);
			//金额时间选择外框
			var showUserPickerButton1 = document.getElementById('UserPicker1');
			var showUserPickerButton2 = document.getElementById('UserPicker2');
			//金额时间选择内容
			var userResult1 = document.getElementById('userResult1');
			var userResult2 = document.getElementById('userResult2');
//			金额时间选择按钮
            showUserPickerButton1.addEventListener('tap', function(event) {
				userPicker.show(function(items) {
					userResult1.innerText = items[0].text;
					serchType(mtype,userResult1.innerText,userResult2.innerText);
					
					
					
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
			showUserPickerButton2.addEventListener('tap', function(event) {
				userPicker1.show(function(items) {
					userResult2.innerText = items[0].text;
					
					//返回 false 可以阻止选择框的关闭
					//return false;
					serchType(mtype,userResult1.innerText,userResult2.innerText);
				});
			}, false);
//		});
//	});
//贷款类型选择/
var kindpick = document.getElementsByClassName('kind-pick');
for(var i = 0; i < 3; i++) {
	kindpick[i].addEventListener('tap', function(event) {
		for(var j = 0; j < 3; j++) {
			if(this == kindpick[j]) {
				this.style.borderColor = '#F26100';
				this.style.color = '#F26100';								
				if(j==3){
					mtype=4;
				}else{
					mtype=j;
				}
//				获取数据函数/
				serchType(mtype,userResult1.innerText,userResult2.innerText);				
				//get(mtype);
			} else {
				kindpick[j].style.borderColor = '#9E9C9C';
				kindpick[j].style.color = 'black';
			}
		}
	});
}
//刷新按钮
refresh.addEventListener('touchstart', function() {
	refresh.style.background = '#D8D8D8';
});
refresh.addEventListener('touchend', function() {
	refresh.style.background = 'white';
	setTimeout(function() {
		refresh.style.display = 'none';
		get(GetQueryString("id"));
	}, 500)
});	
})(window.mui || window, window, document, undefined);

//数据获取函数
function serchType(mtype,money,day){
	var money = userResult1.innerText;
	var day = userResult2.innerText;
	$.ajax({
		type: 'get',
		url: httpAdress + '/api/borrow/product/searchproduct',
		contentType: "application/json;charset=utf-8",
		dataType: 'jsonp',
		data: {
			money:money,
			day:day,
			type_a:GetQueryString("id"),
			type_b:mtype
		},
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {
			var mydata = data.data;
//			console.log()
			var str = '';
			if(mydata.length<10){
					document.getElementById("addmore").innerHTML='没有更多了';
				}
			for(var i = 0; i < mydata.length; i++) {
						var strstart1 = '';
						var strstart2 = '';
						for(var a = 0; a < mydata[i].start; a++) {
							strstart1 += ' <img src="../../img/daikuan/img-star@3x.png"/>'
						}
						for(var b = 0; b < (5 - mydata[i].start); b++) {
							strstart2 += ' <img src="../../img/daikuan/img-star-half@3x.png"/>'
						}
						str +=
							'<li class="mui-table-view-cell mui-media listb">' +
							'<a href="../../HTML/home/home_fast_detail.html?mproid=' + mydata[i].id + '&mdname=' + mydata[i].name + '&mdrate=' + mydata[i].rate + '">' +
							'<img class="mui-media-object mui-pull-left" src="' + httpAdress + mydata[i].logo + '">' +
							'<div class="mui-media-body">' +
							'<div class="top">' +
							' <span class="name">' + mydata[i].name + '</span>' +
							strstart1 + strstart2 +
							'</div>' +
							'<div class="block">' +
							'<span class="mation">下款人数</span><br />' +
							'<span class="num">' + mydata[i].count + '人</span>' +
							'</div>' +
							'<div class="block">' +
							'<span class="mation">月利率</span><br />' +
							'<span class="lilv">' + mydata[i].rate + '</span>' +
							' </div>' +
							'<div class="block">' +
							'<span class="mation">下款时间</span><br />' +
							'<span class="num">' + mydata[i].loan_time + '</span>' +
							'</div></div> </a></li>';
					}
			fast_bord.innerHTML = str;
			
				
		},
		error: function() {
			mui.toast('加载失败，刷新一下');
			refresh.style.display='block';
		}
	});
}

//开始
function get(nn){
		
//		mui.plusReady(function(){
			var fast_bord = document.getElementById('fast_bord');
		$.ajax({
		type: 'get',
		url: httpAdress + '/api/borrow/product/getproductbytype',
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		data: {
			id: nn,
			first:count
		},
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {
			var mydata = data.data;
			var str = fast_bord.innerHTML;
			if(mydata.length==0){
					document.getElementById("addmore").innerHTML='没有更多了';
				}
			for(var i = 0; i < mydata.length; i++) {
						var strstart1 = '';
						var strstart2 = '';
						for(var a = 0; a < mydata[i].start; a++) {
							strstart1 += ' <img src="../../img/daikuan/img-star@3x.png"/>'
						}
						for(var b = 0; b < (5 - mydata[i].start); b++) {
							strstart2 += ' <img src="../../img/daikuan/img-star-half@3x.png"/>'
						}
						str+=
                            '<li class=" mui-media listb">' +
                            '<a class="dispaly-flex" href="'+'../../HTML/home/home_fast_detail.html?mproid=' + mydata[i].id +'&mdname=' + mydata[i].name +'">' +
                            '<img class="item-img mui-media-object mui-pull-left" src="' + httpAdress + mydata[i].logo + '">' +
                            '<div class="mui-media-body">' +
                            '<div class="top">' +
                            ' <span class="mui-media-body-name">' + mydata[i].name + '</span>' +
                            strstart1 + strstart2 +
                            '</div>' +
                            '<div class="block">' +
                            '<span class="mation">下款人数</span><br />' +
                            '<span class="num">' + mydata[i].count + '人</span>' +
                            '</div>' +
                            '<div class="block" style="text-align: center;">' +
                            '<span class="mation">月利率</span><br />' +
                            '<span class="lilv">' + mydata[i].rate + '</span>' +
                            ' </div>' +
                            '<div class="block">' +
                            '<span class="mation">放款时间</span><br />' +
                            '<span class="num">' + mydata[i].loan_time + '</span>' +
                            '</div></div> </a></li>';
//							$('fast_bord').append(str);
					}
			fast_bord.innerHTML = str;	
			if(str==''){					
					document.getElementById("addmore").style.display='none'
			}else{
					document.getElementById("addmore").style.display='block';					
				}
		},
		error: function() {
			mui.toast('加载失败，刷新一下');
			refresh.style.display='block';
		}
	});
			}
var count=0;
get(GetQueryString("id"));
document.getElementById('addmore').addEventListener('tap',function () {
	        count=count+10;
	       get(GetQueryString("id"));
	})
	//			结束
//
//var userup=localStorage.getItem('userid');
//var arrqq = ['../home/home.html', 'daikuan.html', '../bank/credit_card.html', '../login/login.html'];
//var muitabitem = document.getElementsByClassName('mui-tab-item');
//	function change(o){
//		muitabitem[o].addEventListener('tap',function() {
//			document.location.href = arrqq[o];
//			if(o==3&&userup!==null){
//				document.location.href='../my/my.html';
//			}
//		});
//	}
//	for(var i = 0; i < 4; i++) {
//		change(i);
//	}